package com.itheima.demo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class test_5 {
    public static void main(String[] args) throws ParseException {
        System.out.println("请输入你的生日：");

        Scanner sc=new Scanner(System.in);
        String next = sc.next();
        System.out.println(next);
        //这里是创建了一个日期格式化对象
        SimpleDateFormat sdf1=new SimpleDateFormat("yyyy年MM月dd日");
        Date p = sdf1.parse(next);//将生日的String类型转换成date类型再给他转化成long类型的
        long birthy = p.getTime();
        Date date=new Date();
        long time = date.getTime();
        System.out.println("你现在有"+(time-birthy)/1000/60/60/30/12/24+"岁");



    }
}
